<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
	<head>
		<title>blog</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
        <script src="/main/js/jquery.min.js"></script>
        <script src="/main/js/template-web.js"></script>


		<link rel="stylesheet" href="/layui/plugins/layui/css/layui.css" media="all" />
		<script src="/layui/plugins/layui/layui.js"></script>

		<link rel="stylesheet" href="/editmd/css/editormd.css" />
		<link rel="stylesheet" href="/editmd/css/editormd.preview.css" />

		<script src="/editmd/editormd.min.js"></script>

        <script src="/editmd/lib/marked.min.js"></script>
        <script src="/editmd/lib/prettify.min.js"></script>

		<script src="/editmd/lib/raphael.min.js"></script>
		<script src="/editmd/lib/underscore.min.js"></script>
		<script src="/editmd/lib/sequence-diagram.min.js"></script>
		<script src="/editmd/lib/flowchart.min.js"></script>
		<script src="/editmd/lib/jquery.flowchart.min.js"></script>
	</head>
	<body>
    <input type="hidden" id="getUser" th:value="${session.user}"/>
    <input type="hidden" id="getContent" th:value="${content}"/>
	<div style="margin: 15px;">
		<fieldset class="layui-elem-field">
            <legend><button class="layui-btn layui-btn-danger layui-btn-radius" id="insertContent">发表博客</button></legend>
			<div id="test-editormd">  </div>
		</fieldset>
	</div>
        <div class="mini-posts">
                <script type="text/javascript">
                            var newContent;
                            var testEditor;
                            $(function() {
                                   testEditor = editormd("test-editormd", {
                                       width: "90%",
                                       height: 640,
                                       path : '../editmd/lib/',//你的path路径（原资源文件中lib包在我们项目中所放的位置）
                                       imageUpload : true,
                                       imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                                       imageUploadURL : "/uploadFile",
                                       emoji : true,
                                       taskList : true,
                                       saveHTMLToTextarea : true
                                   });
                            });
                            $("#insertContent").bind('click', function(){
								// 在js中调用getMarkdown这个方法可以获得Markdown格式的文本。
                                newContent = testEditor.getMarkdown();
                                push(newContent);

                            });
                </script>

			<script>
				var getUser = document.getElementById("getUser").value;
				var getContent = document.getElementById("getContent").value;
				layui.use([ 'layer', 'element'], function(){
					layer = layui.layer;//弹层
				});
				function get() {
					alert(getUser)
				}
				function push(content) {
					layer.open({
						title:'内容',
						area: ['800px', '550px'],
						type: 2,
						content: '/newPage/submit',
						success:function () {

						}
					});
				}
			</script>
        </div>
	</body>
</html>